﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;

namespace DAL
{
    public class roomtypesDAL
    {
        public static roomtypesmodel showroom()
        {
            string sql = "select * from roomtypes";
            SqlParameter[] para = new SqlParameter[] {
            };
            SqlDataReader reader = DBhelper.ExecuteReaders(sql, para);
            List<roomtypesmodel> list = new List<roomtypesmodel>();
            while (reader.Read())
            {
                roomtypesmodel rm = new roomtypesmodel();
                rm.roomtid = Convert.ToInt32(reader["roomtid"]);
                rm.roomtype = reader["roomtype"].ToString();
                rm.price = reader["price"].ToString();
                list.Add(rm);
            }
            reader.Close();
            return list[0];

        }
        /// <summary>
        /// 显示房间信息
        /// </summary>
        /// <param name="roomtid"></param>
        /// <returns></returns>
        public static roomtypesmodel showmake(string roomtid)
        {
            string sqlstr = "select * from roomtypes where roomtid=@roomtid";
            SqlParameter[] para = new SqlParameter[]
              {

                new SqlParameter("@roomtid",roomtid),
              };
            SqlDataReader reader = DBhelper.ExecuteReaders(sqlstr, para);
            List<roomtypesmodel> list = new List<roomtypesmodel>();
            while (reader.Read())
            {

                roomtypesmodel tr = new roomtypesmodel();
                tr.roomtype = reader["roomtype"].ToString();
                tr.price = reader["price"].ToString();
                list.Add(tr);
            }
            reader.Close();
            return list[0];
        }
    }
}
